import VueRouter from "vue-router";

// import Vue from "vue";
// Vue.use(VueRouter)

const routes = [
    {
        path: '/',
        redirect:'/bookIndex'
    },

    //注册页面
    {
        path: '/register',
        name: 'register',
        component: () =>
            import ('../components/Register')
    },

    //登录页面
    {
        path: '/login',
        name: 'login',
        component: () =>
            import ('../components/AdminLogin')
    },
    //前台页面
    {
        path: '/front',
        name: 'front',
        component: () =>
            import ('../components/view/Index'),
        children: [{ //个人中心
                path: '/mymes',
                name: 'mymes',
                meta: {
                    title: '个人中心'
                },
                component: () =>
                    import ('../components/view/Mymes')
            },
            { //首页
                path: '/bookIndex',
                name: 'bookIndex',
                meta: {
                    title: '首页'
                },
                component: () =>
                    import ('../components/view/bookIndex.vue')
            },
            { //首页
                path: '/shop',
                name: 'shop',
                meta: {
                    title: '商城'
                },
                component: () =>
                    import ('../components/view/Shop.vue')
            },
            { //热销页面
                path: '/hot',
                name: 'hot',
                meta: {
                    title: '热销书籍'
                },
                component: () =>
                    import ('../components/view/Hot.vue')
            },
            { //收藏页面
                path: '/favorites',
                name: 'favorites',
                meta: {
                    title: '收藏夹'
                },
                component: () =>
                    import ('../components/view/Favorites.vue')
            },
            { //新书页面
                path: '/car',
                name: 'car',
                meta: {
                    title: '购物车'
                },
                component: () =>
                    import ('../components/view/Car.vue')
            },
            { //商品的详情页面
                path: '/detail',
                name: 'detail',
                meta: {
                    title: '商品详情'
                },
                component: () =>
                    import ('../components/view/flowerDetail.vue')
            },
              { //我的订单页面
                path: '/orders',
                name: 'orders',
                meta: {
                    title: '我的订单'
                },
                component: () =>
                    import ('../components/view/orders.vue')
            },
             { //修改密码页面
                path: '/updPassword',
                name: 'updPassword',
                meta: {
                    title: '修改密码'
                },
                component: () =>
                    import ('../components/view/updPassword.vue')
            },
              { //收银台页面
                path: '/checkstand',
                name: 'checkstand',
                meta: {
                    title: '收银台'
                },
                component: () =>
                    import ('../components/view/checkstand.vue')
            },
             { //收银台页面
                path: '/address',
                name: 'address',
                meta: {
                    title: '地址'
                },
                component: () =>
                    import ('../components/view/address.vue')
            },
        ]
    },


    //后台页面
    {
        path: '/Index',
        name: 'index',
        component: () =>
            import ('../components/IndexView'),
        children: [{
                path: '/PeopleHome',
                name: 'PeopleHome',
                meta: {
                    title: '首页'
                },
                component: () =>
                    import ('../components/PeopleHome')
            },
            {
                path: '/Order',
                name: 'order',
                meta: {
                    title: '订单管理'
                },
                component: () =>
                    import ('../components/order/OrderManage.vue')
            },
            {
                path: '/User',
                name: 'user',
                meta: {
                    title: '用户管理'
                },
                component: () =>
                    import ('../components/user/UserManage.vue')
            },
            {
                path: '/Book',
                name: 'book',
                meta: {
                    title: '图书管理'
                },
                component: () =>
                    import ('../components/book/BookManage.vue')
            },
            {
                path: '/Type',
                name: 'type',
                meta: {
                    title: '类目管理'
                },
                component: () =>
                    import ('../components/type/TypeManage.vue')
            },
        ]
    }
]

const router = new VueRouter({
    mode: 'history',
    routes
})
const VueRouterPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(to) {
    return VueRouterPush.call(this, to).catch(err => err)
}
export default router;